package com.cg.exception;

import com.cg.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//全局异常处理器
@RestControllerAdvice
public class GlobalExceptionHandler{

    //处理业务异常
    @ExceptionHandler(UserException.class)
    public Result<Exception> handleBusException(UserException ex){
        return new Result<>(400,ex.getMessage(),ex);
    }

    //处理系统异常
    @ExceptionHandler(Exception.class)
    public Result<Exception> handleException(Exception ex){
        return new Result<>(500,"抱歉，服务器出现了异常，正在加紧修复中",ex);
    }
}